<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<script>
    //原理：遍历旧数组 查询新数组，如果元素存在则添加进新数组
    
 function uniqe(arr){
        var newArr = [];
        for(var i = 0;i<arr.length;i++){
           if(newArr.indexOf(arr[i]) === -1){
               newArr[newArr.length] = arr[i];
           } 
        }
        return newArr;
    }console.log(uniqe(['c','z','a','x','a','x','c','b']));
</script>
<body>
    
</body>
</html>